using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Decisions.HL7.Message;
using DecisionsFramework;

namespace Decisions.HL7.Message
{
    public class CountrycodeAttribute:RuleAttribute
    {
        private Dictionary<HL7Version, string[]> validVersionCodes = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, string[]> validVersionDescriptions = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, HL7TableType> tableVersionTypes = new Dictionary<HL7Version, HL7TableType>();

        public CountrycodeAttribute()
        {
            // init the values for table version types
						tableVersionTypes[HL7Version.v24] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v25] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v251] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v26] = HL7TableType.HL7;
			
            
			// init the values for version codes
						validVersionCodes[HL7Version.v24] = new string[]{"ABW","AFG","AFT","AGO","AIA","ALB","AND","ANT","ARE","ARG","ARM","ASM","ATA","ATG","AUS","AUT","AZE","BDI","BEL","BEN","BFA","BGD","BGR","BHR","BHS","BIH","BLR","BLZ","BMU","BOL","BRA","BRB","BRN","BTN","BVT","BWA","CAF","CAN","CCK","CHE","CHL","CHN","CIV","CMR","COD","COG","COK","COL","COM","CPV","CRI","CUB","CXR","CYM","CYP","CZE","DEU","DJI","DMA","DNK","DOM","DZA","ECU","EGY","ERI","ESH","ESP","EST","ETH","FIN","FJI","FLK","FRA","FRO","FSM","GAB","GBR","GEO","GHA","GIB","GIN","GLP","GMB","GNB","GNQ","GRC","GRD","GRL","GTM","GUF","GUM","GUY","HKG","HMD","HND","HRV","HTI","HUN","IDN","IND","IOT","IRL","IRN","IRQ","ISL","ISR","ITA","JAM","JOR","JPN","KAZ","KEN","KGZ","KHM","KIR","KNA","KOR","KWT","LAO","LBN","LBR","LBY","LCA","LIE","LKA","LSO","LTU","LUX","LVA","MAC","MAR","MCO","MDA","MDG","MDV","MEX","MHL","MKD","MLI","MLT","MMR","MNG","MNP","MOZ","MRT","MSR","MTQ","MUS","MWI","MYS","MYT","NAM","NCL","NER","NFK","NGA","NIC","NIU","NLD","NOR","NPL","NRU","NZL","OMN","PAK","PAN","PCN","PER","PHL","PLW","PNG","POL","PRI","PRK","PRT","PRY","PYF","QAT","REU","ROM","RUS","RWA","SAU","SDN","SEN","SGP","SGS","SHN","SJM","SLB","SLE","SLV","SMR","SOM","SPM","STP","SUR","SVK","SVN","SWE","SWZ","SYC","SYR","TCA","TCD","TGO","THA","TJK","TKL","TKM","TMP","TON","TTO","TUN","TUR","TUV","TWN","TZA","UGA","UKR","UMI","URY","USA","UZB","VAT","VCT","VEN","VGB","VIR","VNM","VUT","WLF","WSM","YEM","YUG","ZAF","ZMB","ZWE"};
						validVersionCodes[HL7Version.v25] = new string[]{""};
						validVersionCodes[HL7Version.v251] = new string[]{"..."};
						validVersionCodes[HL7Version.v26] = new string[]{"..."};
			
			// init the values for version descriptions
						validVersionDescriptions[HL7Version.v24] = new string[]{"ARUBA","AFGHANISTAN","FRENCH SOUTHERN TERRITORIES","ANGOLA","ANGUILLA","ALBANIA","ANDORRA","NETHERLANDS ANTILLES","UNITED ARAB EMIRATES","ARGENTINA","ARMENIA","AMERICAN SAMOA","ANTARCTICA","ANTIGUA AND BARBUDA","AUSTRALIA","AUSTRIA","AZERBAIJAN","BURUNDI","BELGIUM","BENIN","BURKINA FASO","BANGLADESH","BULGARIA","BAHRAIN","BAHAMAS","BOSNIA AND HERZEGOVINA","BELARUS","BELIZE","BERMUDA","BOLIVIA","BRAZIL","BARBADOS","BRUNEI DARUSSALAM","BHUTAN","BOUVET ISLAND","BOTSWANA","CENTRAL AFRICAN REPUBLIC","CANADA","COCOS (KEELING) ISLANDS","SWITZERLAND","CHILE","CHINA","COTE D'VOIRE","CAMEROON","CONGO, THE DEMOCRATIC REPUBLIC OF THE","CONGO","COOK ISLAND","COLOMBIA","COMOROS","CAPE VERDE","COSTA RICA","CUBA","CHRISTMAS ISLAND","CAYMAN ISLANDS","CYPRUS","CZECH REPUBLIC","GERMANY","DJIBOUTI","DOMINICA","DENMARK","DOMINICAN REPUBLIC","ALGERIA","ECUADOR","EGYPT","ERITREA","WESTERN SAHARA","SPAIN","ESTONIA","ETHIOPIA","FINLAND","FIJI","FALKLAND ISLANDS (MALVINAS)","FRANCE","FAROE ISLANDS","MICRONESIA, FEDERATED STATES OF","GABON","UNITED KINGDOM","GEORGIA","GHANA","GIBRALTAR","GUINEA","GUADELOUPE","GAMBIA","GUINEA-BISSAU","EQUATORIAL GUINEA","GREECE","GRENADA","GREENLAND","GUATEMALA","FRENCH GUIANA","GUAM","GUYANA","HONG KONG","HEARD ISLAND AND MCDONALD ISLANDS","HONDURAS","CROATIA","HAITI","HUNGARY","INDONESIA","INDIA","BRITISH INDIAN OCEAN TERRITORY","IRELAND","IRAN, ISLAMIC REPUBLIC OF","IRAQ","ICELAND","ISRAEL","ITALY","JAMAICA","JORDAN","JAPAN","KAZAKSTAN","KENYA","KYRGYZSTAN","CAMBODIA","KIRIBATI","SAINT KITTS AND NEVIS","KOREA, REPUBLIC OF","KUWAIT","LAO PEOPLE'S DEMOCRATIC REPUBLIC","LEBANNON","LIBERIA","LIBYAN ARAB JAMAHIRIYA","SAINT LUCIA","LIECHTENSTEIN","SRI LANKA","LESOTHO","LITHUANIA","LUXEMBOURG","LATIVA","MACAU","MOROCCO","MONACO","MOLDOVA, REPUBLIC OF","MADAGASCAR","MALDIVES","MEXICO","MARSHALL ISLANDS","MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF","MALI","MALTA","MYANMAR","MONGOLIA","NORTHERN MARIANA ISLANDS","MOZAMBIQUE","MAURITANIA","MONTSERRAT","MARTINIQUE","MAURITUS","MALAWI","MALAYSIA","MAYOTTE","NAMIBIA","NEW CALEDONIA","NIGER","NORFOLK ISLAND","NIGERIA","NICARAGUA","NIUE","NETHERLANDS","NORWAY","NEPAL","NAURU","NEW ZEALAND","OMAN","PAKISTAN","PANAMA","PITCAIRN","PERU","PHILIPPINES","PALAU","PAPUA NEW GUINEA","POLAND","PUERTO RICO","KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF","PORTUGAL","PARAGUAY","FRENCH POLYNESIA","QATAR","REUNION","ROMANIA","RUSSIAN FEDERATION","RWANDA","SAUDI ARABIA","SUDAN","SENEGAL","SINGAPORE","SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS","SAINT HELENA","SVALBARD AND JAN MAYEN","SOLOMON ISLANDS","SIERRA LEONE","EL SALVADOR","SAN MARINO","SOMALIA","SAINT PIERRE AND MIQUELON","SAO TOME AND PRINCIPE","SURINAME","SLOVAKIA","SLOVENIA","SWEDEN","SWAZILAND","SEYCHELLES","SYRIAN ARAB REPUBLIC","TURKS AND CAICOS ISLANDS","CHAD","TOGO","THAILAND","TAJIKISTAN","TOKELAU","TURKMENISTAN","EAST TIMOR","TONGA","TRINIDAD AND TOBAGO","TUNISIA","TURKEY","TUVALU","TAIWAN, PROVINCE OF CHINA","TANZANIA, UNITED REPUBLIC OF","UGANDA","UKRAINE","UNITED STATES MINOR OUTLYING ISLANDS","URUGUAY","UNITED STATES","UZBEKISTAN","HOLY SEE  (VATICAN CITY STATE)","SAINT VINCENT AND THE GRENADINES","VENEZUELA","VIRGIN ISLANDS, BRITISH","VIRGIN ISLANDS, U.S.","VIET NAM","VANUATU","WALLIS AND FUTUNA","SAMOA","YEMEN","YUGOSLAVIA","SOUTH AFRICA","ZAMBIA","ZIMBABWE"};
						validVersionDescriptions[HL7Version.v25] = new string[]{""};
						validVersionDescriptions[HL7Version.v251] = new string[]{"use 3-character (alphabetic) form of ISO 3166"};
						validVersionDescriptions[HL7Version.v26] = new string[]{"use 3-character (alphabetic) form of ISO 3166"};
			            

        }

        
        public override ValidationIssue[] RunRule(string name, object owningObject, object value)
        {
            //todo: check if the value is valid in the current version
            //if the value is not valid in the current version, add it as a validation issue


            return new ValidationIssue[0];
        }
    }
}
